package demo02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;

/*
 *  static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)：该方法用于将两个流合并为一个流
 */
public class Demo07StreamConcat {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Collections.addAll(list, "土司鸡", "老虎", "粹花");
        Set<String> set = new HashSet<>();
        Collections.addAll(set, "提莫", "哈利");
        String[] strings = { "小玉", "小丸子" };

        Stream<String> stream1 = list.stream();
        Stream<String> stream2 = set.stream();
        Stream<String> stream3 = Stream.of(strings);
        Stream<String> bigStream = Stream.concat(Stream.concat(stream1, stream2), stream3); // 流1和流2合并，其结果和流3合并
        bigStream.forEach(string -> System.out.println(string)); // 土司鸡 老虎 粹花 提莫 哈利 小玉 小丸子
    }
}
